/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.progin.cloudfolder.service;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Driver for services
 * @author Ecky
 */
public class ServiceMain {

    public static void main(String[] args) throws IOException {
        //Prepare socket
        ServerSocket s = new ServerSocket(args.length < 1 ? 8787 : Integer.parseInt(args[0]));
    	System.out.println("Server created at " + s.getInetAddress() + ", port " + s.getLocalPort());
    	
        //Run wild!
        while(true) {
            try {
                new Thread(new CloudFolderService(s.accept())).start();
            } catch (IOException ex) {
                Logger.getLogger(ServiceMain.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
}
